package com.chixing.ih.module.programmer.mapper;


import com.chixing.ih.module.programmer.mapper.provider.ProgrammerMapperProvider;
import com.chixing.ih.module.programmer.pojo.Programmer;
import com.chixing.ih.module.programmer.pojo.dto.*;

import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;


/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘岩
 * Date: 2020-09-24
 * Time: 19:59
 *
 * @version 1.0
 */
@Mapper
public interface ProgrammerMapper {

    @UpdateProvider(type = ProgrammerMapperProvider.class, method = "updateOne")
    int updateOne(Programmer programmer);

    @UpdateProvider(type = ProgrammerMapperProvider.class, method = "updateInfo")
    int updateOneByInfo(Programmer programmer);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getOneById")
    @Results(id = "programmerMap", value = {
            @Result(id = true, column = "user_id", property = "programmerId"),
            @Result(column = "user_account", property = "programmerAccount"),
            @Result(column = "nick_name", property = "nickName"),
            @Result(column = "user_password", property = "programmerPassword"),
            @Result(column = "user_telephone", property = "programmerTelephone"),
            @Result(column = "user_status", property = "programmerStatus"),
            @Result(column = "user_career", property = "programmerCareer"),
            @Result(column = "user_email", property = "programmerEmail"),
            @Result(column = "user_introduction", property = "programmerIntroduction"),
            @Result(column = "user_career_direct", property = "programmerCareerDirect"),
            @Result(column = "user_position", property = "programmerPosition"),
            @Result(column = "user_company", property = "programmerCompany"),
            @Result(column = "alipay_account", property = "alipayAccount"),
            @Result(column = "wechat_account", property = "wechatAccount"),
            @Result(column = "qq_account", property = "qqAccount"),
            @Result(column = "support_num", property = "supportNum"),
            @Result(column = "role_id", property = "roleId"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "is_deleted", property = "isDeleted")

    })
    Programmer getOne(long programmerId);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getUserIds")
    List<Integer> getUserIds();

    @UpdateProvider(type = ProgrammerMapperProvider.class, method = "updatePassword")
    int updatePassword(ProgrammerDTO programmerDTO);

    @UpdateProvider(type = ProgrammerMapperProvider.class, method = "updatePerIntroduce")
    int updatePerIntroduce(Programmer programmer);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getPerIntroduce")
    @Results(id = "perIntroduceMap", value = {
            @Result(column = "user_introduction", property = "programmerIntroduction"),
    })
    PerIntroduceDTO getPerIntroduce(long programmerId);


//    @Results(id = "programmerListMap", value = {
//            @Result(id = true, column = "user_id", property = "userId"),
//            @Result(column = "nick_name", property = "nickName"),
//            @Result(column = "user_career", property = "programmerCareer"),
//            @Result(column = "user_company", property = "programmerCompany"),
//            @Result(column = "image_url", property = "imageUrl"),
//            @Result(column = "star_rating", property = "starRating"),
//            @Result(column = "work_way", property = "workWay"),
//            @Result(column = "region_city", property = "regionCity"),
//            @Result(column = "salary", property = "salary"),
//            @Result(column = "working_day_begin_time", property = "WDBT"),
//            @Result(column = "working_day_end_time", property = "WDET"),
//            @Result(column = "weekend_working_begin_time", property = "WWBT"),
//            @Result(column = "weekend_working_end_time", property = "WWET"),
//    })
//    @SelectProvider(type = ProgrammerMapperProvider.class, method = "listAll")
//    List<ProgrammerListDTO> listAll();


    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getOneApply")
    @Results(id = "programmerEntiretyMap", value = {
            @Result(id = true, column = "user_id", property = "userId"),
            @Result(column = "nick_name", property = "nickName"),
            @Result(column = "user_career", property = "programmerCareer"),
            @Result(column = "user_company", property = "programmerCompany"),
            @Result(column = "image_url", property = "imageUrl"),
            @Result(column = "star_rating", property = "starRating"),
            @Result(column = "work_way", property = "workWay"),
            @Result(column = "region_city", property = "regionCity"),
            @Result(column = "user_email", property = "programmerEmail"),
            @Result(column = "salary", property = "salary"),
            @Result(column = "working_day_begin_time", property = "WDBT"),
            @Result(column = "working_day_end_time", property = "WDET"),
            @Result(column = "weekend_working_begin_time", property = "WWBT"),
            @Result(column = "weekend_working_end_time", property = "WWET"),
    })
    ProgrammerEntiretyDTO getOneApply(long userId);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "listAllNum")
    long listAllNum();

    @UpdateProvider(type = ProgrammerMapperProvider.class, method = "updateTime")
    int updateTime(@Param("userId") long userId, @Param("updateTime") Date updateTime);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "findAllByCondition")
    @Results(id = "programmerListMap", value = {
            @Result(id = true, column = "user_id", property = "userId"),
            @Result(column = "nick_name", property = "nickName"),
            @Result(column = "user_career", property = "programmerCareer"),
            @Result(column = "user_company", property = "programmerCompany"),
            @Result(column = "image_url", property = "imageUrl"),
            @Result(column = "star_rating", property = "starRating"),
            @Result(column = "work_way", property = "workWay"),
            @Result(column = "region_city", property = "regionCity"),
            @Result(column = "salary", property = "salary"),
            @Result(column = "working_day_begin_time", property = "WDBT"),
            @Result(column = "working_day_end_time", property = "WDET"),
            @Result(column = "weekend_working_begin_time", property = "WWBT"),
            @Result(column = "weekend_working_end_time", property = "WWET"),
    })
    List<ProgrammerListDTO> findAllByCondition(String programmerCareer, String workPlace, Integer workWay,
                                               List<Integer> list);

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getProgrammers")
    List<ProgrammerHomeDTO> getProgrammers();

    @SelectProvider(type = ProgrammerMapperProvider.class, method = "getRecommend")
    List<RecommendProgrammer>getRecommend(String userCareer, Integer userId);


}
